<%@ page pageEncoding="utf-8"%> 
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@page import="com.course.db.*"%>

<%
	request.setAttribute("layout","main.jsp");
	request.setAttribute("page_title","温岭选课系统-课程申报审核");
	int i = 0;
  	List<Hashtable<String, String>> adminList = (List<Hashtable<String, String>>) session.getAttribute("AdminList");
	Iterator<Hashtable<String, String>> adminList_it = adminList.iterator();
	//CourseBasic course = (CourseBasic)session.getAttribute("CheckCourse");
	CourseTerm courseterm = (CourseTerm)session.getAttribute("CourseTerm");
 %>
	<link href="css/jquery.ui.tabs.css" rel="stylesheet">
	<link href="css/jquery.ui.theme.css" rel="stylesheet">
	<link href="css/div_win.css" rel="stylesheet"> 
	<script src="js/div_win.js"></script>
	<script src="js/jquery-1.5.2.min.js"></script>
	<script src="js/jquery-ui-1.8.11.custom.min.js"></script>
	<script src="js/jquery.ui.tabs.js"></script>
	<script type="text/javascript" src="js/popup.js"></script>
	
	<script>
	$(function() {
		$( "#tabs" ).tabs();
	});
	
	function edit(courseId){
	   $.ajax({
			url: base_path+"Admin/edit.do",
			type: "POST",
			data: {"method":"measuring"},
            data: {"courseId":courseId}, 
			beforeSend: function(XMLHttpRequest){
			},
			success: function(data, textStatus){
				if(data=="success"){
				
				}else{ 
				
				}
			},

			complete: function(XMLHttpRequest, textStatus){
				ShowIframe('编辑课程信息',base_path+"admin/courseEdit.jspx?courseId=+id",700,550);
			},
			error: function(){
				$("#ajaxResult").html("服务器异常，请联系网络管理员");
			}
		});
   }
   
   	function open_frame(id){
		//ShowIframe('审批课程申请',base_path+"admin/courseApplyApproveDetail.jspx?courseId="+id,700,600);
		//alert(base_path+"admin/courseApplyApproveDetail.jspx?courseId="+id);
	}
   
   	function editselect1(idlist){
 	   $.ajax({
 			url: base_path+"Admin/idlist.do",
 			type: "POST",
             data: {"idlist":idlist}, 
 			beforeSend: function(XMLHttpRequest){
 			},
 			success: function(data, textStatus){
 				if(data=="success"){
 				}else{
 				}
 			},

 			complete: function(XMLHttpRequest, textStatus){
 				ShowIframe('课程批量编辑',base_path+"admin/editselectCourse.jspx",550,300);
 			},
 			error: function(){
 				$("#ajaxResult").html("服务器异常，请联系网络管理员");
 			}
 		});
    }
   	
   	function editselect(){
   		
   		var s=''; 
   		var i=0;
   	   	$('input[name="idlist"]:checked').each(function(){
   	   	    s+=$(this).val()+",";
   	   	});
   	   	//alert(s.length);
   		//alert("edit select");
   		//alert(s);
   		editselect1(s);
	   	//document.listform.submit();
	   	
   		//ShowIframe('课程批量编辑',base_path+"admin/editselectCourse.jspx",550,300);
	}
	
	</script>
	<script type='text/javascript'>
	function submitcourse()
	{
		var span_v = document.getElementById('course_span').value;
		var credit_v = document.getElementById('credit').value;
		var students_max_v = document.getElementById('students_max').value;
		var students_min_v = document.getElementById('students_min').value;
		
		if(String(parseInt(students_max_v))!== students_max_v || String(parseInt(students_min_v))!== students_min_v)
		{
			alert("限制人数必须为整数!");
			document.getElementById('students_max').focus;
			return false;
		}
		
		if(isNaN(span_v) || isNaN(credit_v))
		{
			alert("总学时数或课程学分不是有效的数字!");
			return false;
		}

	   	document.applyform.submit();
	}
</script>
<div style="width:100%; margin:1px;text-align:center;margin-top:5px;margin-bottom:20px;">
 	
 	<p style="border:0;font-size:14px;padding-bottom:0;text-align:center;">
 	<!-- 	<b>课程申报记录</b>
  		<select>
  			<option value="全部">全部</option>
  			<option value="2011年第一学期">2011年第一学期</option>
  			<option value="2011年第二学期">2011年第二学期</option>
  			<option value="2012年第一学期">2012年第一学期</option>
  		</select>
	 -->
	</p>
	  <div id="tabs" style="height:100%;width:90%;margin-left:5%;">
		<ul>
			<li><a href="#tabs-1">管理课程</a></li>
			<li><a href="#tabs-2">新建课程</a></li>
		</ul>
		<div id="tabs-2" style="width:100%;margin-left:0;padding-left:0;margin-top:20px;">
			<style>
	tr{
		height:30px;
	}
	.tdLeft{
		align:left;
		text-align:left;
		padding-left:20px;
		
	}
</style>
<div style="width:100%; margin:1px;text-align:center;margin-top:10px;margin-bottom:50px;">
 	<p style="border:0;font-size:14px;padding-bottom:0;">
  		<b>浙江省温岭中学课程申报表</b>
	</p>
		<form action="Teacher/apply.do?src=admin" name="applyform" method="post">
 		<table style="width:80%; margin-left:10%;">
 			<tr>
 				<td>授课教师</td>
 				<td class="tdLeft"><input type="text" size="20" name="teacher_name" /></td>
 			</tr>
 			<tr>
 				<td>课程分类</td>
 				<td class="tdLeft">
 					<select style="width:160px;" name="course_type">
 						<option value="知识拓展">知识拓展</option>
 						<option value="大学初级课程">大学初级课程</option>
 						<option value="学科应用">学科应用</option>
 						<option value="兴趣特长培养">兴趣特长培养</option>
 						<option value="社会实践活动">社会实践活动</option>
 						<option value="职业技术培训">职业技术培训</option>
 					</select>
 				</td>
 			</tr>
 			<tr>
 				<td>课程名称</td>
 				<td class="tdLeft"><input type="text" size="50" name="course_name"/></td>
 			</tr>
 			<tr>
 				<td>总学时数</td>
 				<td class="tdLeft"><input type="text" size="20" name="course_span" id="course_span"/></td>
 			</tr>
 			<tr>
 				<td>课程学分</td>
 				<td class="tdLeft"><input type="text" size="20" name="credit" id="credit"/></td>
 			</tr>
 			<tr>
 				<td>限制人数</td>
 				<td class="tdLeft"><input type="text" size="10" name="students_max" id="students_max"/>/<input type="text" size="10" name="students_min" id="students_min"/> (最多/最少)</td>
 			</tr>
 			<tr>
 				<td>开课时间</td>
 				<td class="tdLeft">
 					<select style="width:80px;" name="year">
 						<option value="2012年">2012年</option>
 						<option value="2013年">2013年</option>
 						<option value="2014年">2014年</option>
 					</select>&nbsp;&nbsp;&nbsp;&nbsp;
 					<input type="checkbox" name="term" value="第一学期" />第一学期&nbsp;&nbsp;
 					<input type="checkbox" name="term" value="第二学期" />第二学期&nbsp;&nbsp;
 					<input type="checkbox" name="term" value="第三学期" />第三学期&nbsp;&nbsp;
 					<input type="checkbox" name="term" value="第四学期" />第四学期&nbsp;&nbsp;
 				</td>
 			</tr>
 			<tr>
 				<td>面向年级</td>
 				<td class="tdLeft">
 					<input type="checkbox" name="grade" value="高一年级" />高一年级&nbsp;&nbsp;
 					<input type="checkbox" name="grade" value="高二年级" />高二年级&nbsp;&nbsp;
 					<input type="checkbox" name="grade" value="高三年级" />高三年级&nbsp;&nbsp;
 				</td>
 			</tr>
 			<tr>
 				<td>上课时间</td>
 				<td class="tdLeft"><input type="text" size="50" name="time"/></td>
 			</tr>
 			<tr>
 				<td>上课地点</td>
 				<td class="tdLeft"><input type="text" size="50" name="location"/></td>
 			</tr>
 			<tr>
 				<td>教学方式</td>
 				<td class="tdLeft"><input type="text" size="50" name="teach_style"/></td>
 			</tr>
 			<tr>
 				<td>考核方式</td>
 				<td class="tdLeft">
 				<!-- <input type="text" size="50" name="test_style"/> -->
 				<select style="width:80px;" name="test_style">
 						<option value="分数制">分数制</option>
 						<option value="等级制">等级制</option>
 						<option value="其它">其它</option>
 				</select>
 				</td>
 			</tr>
 			<tr>
 				<td>教学所属设备</td>
 				<td class="tdLeft"><textarea cols=50 rows=5 name="equipments" style="margin-top:5px;margin-bottom:5px;"></textarea></td>
 			</tr>
 			<tr>
 				<td>课程简介</td>
 				<td class="tdLeft"><textarea cols=50 rows=5 name="introduction"  style="margin-top:5px;margin-bottom:5px;"></textarea></td>
 			</tr>
 		</table>
		<div id="btn" style="width:100%;align:right;">
			<!--  <a href="javascript:opencourse();" style="margin-left:80%;">保存</a> -->
			<input type="reset" name="Reset" value="重置"  style="margin-left:58%;"/>&nbsp;&nbsp;&nbsp;&nbsp;
      		<input type="button" name="Submit" value="提交" onclick="javascript:submitcourse()" />
		</div>
		</form>
</div>
		</div>
		<div id="tabs-1" style="width:100%;margin-left:0;padding-left:0;margin-top:20px;">
			<form action="Admin/idlist.do" name="listform" method="post">
			<table>
		    		<tbody>
		              <tr height="32" bgcolor="#f0f0f0">
		                    <td align="center" width="3%">选择</td>
		                    <td align="center" width="7%">课程编号</td>
		              		<td align="center" width="10%">学期</td>
		                    <td align="center" width="8%">课程类型</td>
		                    <td align="center" width="8%">课程名称</td>
		                    <td align="center" width="8%">授课老师</td>
                       		<td align="center" width="6%">课程状态</td>
		                  <td align="center" width="6%">人数限额<br>
                      (最少/最多)</td>
		                    <td align="center" width="18%">操作</td>
		             </tr>
			  		   <%
			  		 adminList_it = adminList.iterator();
		        		while(adminList_it.hasNext())
							{
								Hashtable<String, String> adminList_hash  = adminList_it.next();
					%>
			  		  <tr height="25" bgcolor="#ffffff">
			  		  	 <td align="center"><input type="checkbox" name="idlist" id="idlist" value="<%=adminList_hash.get("Id") %>"/></td>
		                 <td align="center"><%=adminList_hash.get("classno") %></td>
			  		  	 <td align="center"><%=adminList_hash.get("year") %><%=adminList_hash.get("openterm") %></td>
		                 <td align="center"><%=adminList_hash.get("type") %></td>
		                 <td align="center"><%=adminList_hash.get("name") %> </td>
		                 <td align="center"><%=adminList_hash.get("teachers") %> </td><td align="center">
		                 	<% if(adminList_hash.get("checkstatus").equalsIgnoreCase("0")){%>
			             		审核中
				             	<% }else if(adminList_hash.get("checkstatus").equalsIgnoreCase("1")){ %>
				             		审核通过
				             	<%}else if(adminList_hash.get("checkstatus").equalsIgnoreCase("2")){ %>
				             		审核不通过
				             	<%}else if(adminList_hash.get("checkstatus").equalsIgnoreCase("3")){ %>
				             		选课中
				             	<%}else if(adminList_hash.get("checkstatus").equalsIgnoreCase("4")){ %>
				             		开课
				             	<%}else if(adminList_hash.get("checkstatus").equalsIgnoreCase("5")){ %>
				             		结束
				             	<%} %>
				             	
		                 </td>
		             <td align="center"><%=adminList_hash.get("students_low")%>/<%=adminList_hash.get("students_high")%></td>  
		              <td align="center">
		              	<%if(adminList_hash.get("checkstatus").equalsIgnoreCase("0")||adminList_hash.get("checkstatus").equalsIgnoreCase("1")||adminList_hash.get("checkstatus").equalsIgnoreCase("2")){ %>
			              <a href="javascript:edit(courseId=<%=adminList_hash.get("Id") %>)" class="approve" >编辑</a> &nbsp;|&nbsp;
			              <a href="Admin/delete.do?courseId=<%=adminList_hash.get("Id") %>"  class="approve"  >删除</a>&nbsp;|&nbsp;
			              
			            <%}else{ %>
			             	<font color="#aaaaaa">编辑 </font>&nbsp;|&nbsp;
			              	<font color="#aaaaaa">删除</font>&nbsp;|&nbsp;
			              	
			            <%} %>
			            
			            <%if(adminList_hash.get("checkstatus").equalsIgnoreCase("0")||adminList_hash.get("checkstatus").equalsIgnoreCase("1")){ %>
			              <a href="Admin/delopy.do?courseId=<%=adminList_hash.get("Id") %>" class="approve"  >发布</a>&nbsp;|&nbsp;
			            <%}else if(adminList_hash.get("checkstatus").equalsIgnoreCase("3")) {%>
			              <a href="Admin/delopy.do?courseId=<%=adminList_hash.get("Id") %>&type=uncheck" class="approve"  >取消</a>&nbsp;|&nbsp;
			            <%}else{ %>
			                <font color="#aaaaaa">发布</font>&nbsp;|&nbsp;
			            <%} %>
			              <a href="Admin/detail.do?courseId=<%=adminList_hash.get("Id") %>"  class="approve" >查看</a></td>
		              </tr>
			          <%
			          }
			          %>
		      </tbody>
		   </table>
		   <div id="btn">
				<a href="javascript:editselect();">编辑所选</a>
		   </div>
		   </form>
		</div>
	</div>
</div>
